﻿//don't delete this row
//this.contextPath();
//alert("core"); //輝

// p 輝 
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- Start ------------------------------------- */
/*--------------------------- p ----------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
  
function addP(el){
	var pos = new p();
	pos.assign(el);
}
function p(x, y, z, width, height, alpha){
	this.el = null;
	this.x = (x != undefined) ? x : null;
	this.y = (y != undefined) ? y : null;
	this.z = (z != undefined) ? z : null;
	this.width = (width != undefined) ? width : null;
	this.height = (height != undefined) ? height : null;
	this.alpha = (alpha != undefined) ? alpha : null; 
	this.setX = function(x){
		if(x != undefined){
			this.x = x;
			this.el.style.position = "absolute";
			CE.setLeft(this.el, x);
		}			
	}
	this.setY = function(y){
		if(y != undefined){
			this.y = y;
			this.el.style.position = "absolute";			
			CE.setTop(this.el, y);
		}
	}
	this.setZ = function(z){
		if(z != undefined)		
			this.z = z;
	}
	this.setWidth = function(width){
		if(width != undefined){
			this.width = width;
			CE.setWidth(this.el, width);
		}
	}
	this.setHeight = function(height){
		if(height != undefined){
			this.height = height;
			CE.setHeight(this.el, height);
		}
	}
	this.setAlpha = function(alpha){
		if(alpha != undefined)		
			this.alpha = alpha; 
	}
	this.set = function(x, y, z, width, height, alpha){
		this.setX(x);
		this.setY(y);
		this.setZ(z);
		this.setWidth(width);
		this.setHeight(height);
		this.setAlpha(alpha);
	}	
	this.assign = function(el){
		el.p = this;
		this.el = el;
	}		
}






 



/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- End --------------------------------------- */
/* -------------------------- p ----------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


window.onload = function() {
	CE.initContextPath();			
	CE.pmr.init(); 
	if(typeof PU != "undefined") 	PU.init();	
	if(typeof STYLE != "undefined")	STYLE.init(4);	
//	if(typeof TB != "undefined") 	TB.init();
//	if(typeof LT != "undefined") 	LT.init();
//	if(typeof ST != "undefined") 	ST.init();
//	if(typeof FM != "undefined") 	FM.init();
//	if(typeof HC != "undefined")  	HC.init();
//	if(typeof LL != "undefined") 	LL.init();
	if(typeof MU != "undefined") 	MU.init();
//	if(typeof CG != "undefined")  	CG.init();
	if(typeof CR != "undefined")  	CR.init();	
	CE.addEventListener(document, "keydown", CE.documentOnKeyDown);
	CE.addEventListener(document, "keyup", CE.documentOnKeyUp);	
	CE.addEventListener(document, "mousedown", CE.documentOnMouseDown);	
	CE.addEventListener(document, "mouseup", CE.documentOnMouseUp);
	try{
		//dummyMenu();
		//CE.transformHiddenField(document);
		bodyOnLoad();
		//initHdrBtn();		
	}catch(e){
	}	
}

/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- Start ------------------------------------- */
/* -------------------------- Append Body onload function --------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */

window.addLoadEvent = function(func) {
   var oldonload = window.onload;
   if (typeof window.onload != "function") {
      window.onload = func;
   } else {

      window.onload = function() {
         if (oldonload) {			 
            oldonload();
         }
         func();
      }
   }
}
window.addLoadEvent(function() { CE.init(); });   

/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- End --------------------------------------- */
/* -------------------------- Append Body onload function --------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
 




/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------- Start ----------------------------------- */
/*STYLE ------------------------ STYLE Function ------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */

 
var STYLE = {
	currentStyle : null,
	previousStyle : null,	
	linkAry : new Array(),
	init : function(noOfLink){
		if(CE.getCookie("changeByKeyPress") == null){
			CE.setCookie("changeByKeyPress", "false", "");
		}
		for(var i=0; i<noOfLink; i++){
			var _link = CE.createElement("link",
				{
					rel : "stylesheet",
					type : "text/css",
					href : "/*"
				},
				null,
				document.body
			);
			this.linkAry[i] = _link;
			this.linkAry[i].href = "../css/dummy.css";
		}
		/*-- color theme --------------------------------------------------*/		
		var themeNum = null;		
		function checkThemeAtCookie(){
			if(CE.getCookie("theme") == null){
				themeNum = 1;
				CE.setCookie("theme", themeNum);	
			}else{
				themeNum = CE.getCookie("theme");
				if(CE.getCookie("changeByKeyPress") == "true"){
					//STYLE.changeStyle(themeNum);
				}
			}	
		}
		if(CE.pmr.exist){
			if(CE.pmr.theme != undefined){
				themeNum = CE.pmr.theme;
			}else{
				checkThemeAtCookie();				
			}
		}else{
				checkThemeAtCookie();
		}
		/*-- color theme --------------------------------------------------*/		
		
		/*-- font size --------------------------------------------------*/
		var fontSizeNum = null;		
		function checkFontSizeAtCookie(){
			if(CE.getCookie("fontSize") == null){
				fontSizeNum = 1;
				CE.setCookie("fontSize", fontSizeNum);	
			}else{
				fontSizeNum = CE.getCookie("fontSize");
			}	
		} 
		//checkFontSizeAtCookie();	 
		//this.changeFontSize(fontSizeNum);
		/*-- font size --------------------------------------------------*/		
		if(CE.browser("IE6")){
			this.linkAry[3].href = "../css/screen_IE6.css";
		}
	},	
	changeFontSize : function(number){
		this.linkAry[2].href = "../css/font_size_" + number + ".css";
		CE.setCookie("fontSize", number);
	},
	disableIncludedCSS : function(){
		var _menu = CE.$("menuCSS");
		if(_menu != null){
			_menu.href = "../css/dummy.css";
		}
		var _screen = CE.$("screenCSS");
		if(_screen != null){
			_screen.href = "../css/dummy.css";
		}
	},
	changeStyle : function(number){
		this.disableIncludedCSS();
		var _files = ["screen.css", "menu.css"];
		for(var i=0; i<_files.length; i++){ 
			this.linkAry[i].href = "../theme/color_" + number + "/css/" + _files[i];
		}
		CE.setCookie("theme", number);
		if(CE.$("homeNavIcon") != null){
			CE.$("homeNavIcon").title = number;
			this.currentStyle = number;
		}
	},	
	changeFontSizeByKeyPress : function(e){ 
		//ctrlKey, altKey, shiftKey
			//112 - F1
			//113 - F2
			//114 - F3
		if(e.altKey == true){		
			if(e.keyCode == 112){
				this.changeFontSize(1);
			}
			if(e.keyCode == 113){
				this.changeFontSize(2);
			}
			if(e.keyCode == 114){
				this.changeFontSize(3);
			}
		}
	},
	changeStyleByKeyPress : function(e){ 
		//ctrlKey, altKey, shiftKey
		//0 - 48
		//9 - 57 
		if(e.altKey == true){
			if(e.keyCode == 81){ //Q
				if(CE.getCookie("changeByKeyPress") == "false"){
					CE.setCookie("changeByKeyPress", "true", "");
				}else{
					CE.setCookie("changeByKeyPress", "false", "");
				}
				//CE.alert(CE.getCookie("changeByKeyPress"));
			}
			if(e.keyCode >= 48 && e.keyCode <= 57){
				var _num = e.keyCode - 48;
				this.changeStyle(_num);
				CE.setCookie("changeByKeyPress", "true", "");
			}
		}
	}
}
function printPreview(e){
	var _thisObj = CE.eventObj(e);	
	
	var _buttons = CE.getElementsByClassName(document, "input", "inputButton", true);
	for(var i=0; i<_buttons.length; i++){
		if(_buttons[i].onclick != null){
			if(_buttons[i].onclick.toString().indexOf("printPreview") != -1){				
				if(_buttons[i].printMode == undefined || _buttons[i].printMode == false){
					if(STYLE.currentStyle != 0){
						STYLE.previousStyle = STYLE.currentStyle;
						STYLE.changeStyle(0);
					}
					_buttons[i].printMode = true;
					_buttons[i].previousText = _buttons[i].value;
					_buttons[i].value = "Cancel Print Preview";		
			//		window.print();		
				}else{
					_buttons[i].printMode = false;
					_buttons[i].value = _buttons[i].previousText;
					STYLE.changeStyle(STYLE.previousStyle);	
				}				
			}
		}	
	}
	if(_thisObj.printMode == true){
		window.print();		
	}		
}
 
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ------------------------------ END ----------------------------------- */
/*STYLE ------------------------ STYLE Function ------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */









/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------- Start ----------------------------------- */
/*CE ------------------------ Core Function ----------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */

var CE = {
	id : "CE",
	zIndex : 0,	//for all objects
	errorBox : null,
	errCount : 0,	
	aniDelta : new Object,
	basePath : "",
	txtDmyDiv : null,
	pmr : {
		id : "parameterID",
		exist : false,
		init : function(){
			var pmrStr = window.location.search.toString();
			pmrStr = pmrStr.substr(1, pmrStr.length);
			if(pmrStr != ""){
				this.exist = true;
				var andStr = pmrStr.split("&");
				for(var i=0; i<andStr.length; i++){
					if(andStr[i].indexOf("=") != -1){
						var equStr = andStr[i].split("=");
						this[equStr[0]] = equStr[1];
					}
				}
			}			
		},
		checkPmr : function(){
			CE.alert(this.exist);
		}
	},		
	window : {
		close : function(id){
			if(CE.browser() == "IE"){ 
				window.opener='X';	
			}else{
				window.open('','_parent','');				
			}
			window.close();
		}
	},	
	init : function(){	
//		if(typeof TB != "undefined") 	TB.init();		
//		if(typeof LT != "undefined") 	LT.init();
//		if(typeof ST != "undefined") 	ST.init();
//		if(typeof FM != "undefined") 	FM.init();
	},
	bodyOnload : function(){
//		if(typeof TB != "undefined") 	TB.init();		
//		if(typeof LL != "undefined") 	LL.init();
		//CE.disableRightClick();
	},
	isEnglish : function (str) {
		var ret = false;		
		var result = null;
		var re = new RegExp();
		re = /[^\s\w`~!@#$%^&*()_+=\[\]\|\\:;"'<,>.?\/-]/g;
		result = str.match(re);
		if(result != null){
			ret = false	
		}else{
			ret = true;
		}
		CE.alert(result);
		return ret;
	},
	keyChar : function (e) {
		var keyCode = e.keyCode;
		var char = String.charCodeAt(keyCode);
		return char;
	},
	keyCharIsEscapeKey : function (e) {
		var keyCode = e.keyCode;
		var flag = false;
		if( keyCode == 8 ||	//back
			keyCode == 46 ||	//del
			keyCode == 9 ||	//tab
			keyCode == 13 ||	//enter
			keyCode == 110 // . 
		   )
		{
			flag = true;
		}
		return flag;		
	},
	keyCharIsNum : function (e) {
		var keyCode = e.keyCode;
		var flag = false;
		if((keyCode >= 48 && keyCode <= 57) ||
			(keyCode >= 96 && keyCode <= 105) ||
			 CE.keyCharIsEscapeKey(e)
		   )
		{
			flag = true;
		}
		return flag;
	},
	$ : function (id) {
		if(document.getElementById(id) != null){
			if(document.getElementById(id).p == undefined){
				addP(document.getElementById(id));
			}
		}
		return document.getElementById(id);
	},	
	$s : function (base, tag) {
		return base.getElementsByTagName(tag);
	},
	$insert : function (base, obj) {
		base.parentNode.insertBefore(obj, base);
	},
	insertAfter : function( referenceNode, newNode ) {
		referenceNode.parentNode.insertBefore( newNode, referenceNode.nextSibling );
	},
	$append : function (base, obj) {
		base.parentNode.appendChild(obj);
	},
	$clone : function (obj, name, cloneChild) {
		if(cloneChild == undefined){
			cloneChild = false;
		}
		var i = obj.selectedIndex;
		var tmpObj = obj.cloneNode(cloneChild);
		tmpObj.selectedIndex = i ;
		if(name != undefined){
			tmpObj.name = name;
			tmpObj.id = name;
		}
		return tmpObj;
	},		
	selectGroup : function(){
		function selectOnChange(e){
			var thisObj = CE.eventObj(e);
			var selectedValue = CE.selected(thisObj, "value");						
			var next = thisObj._sNext;
			if(next != null){
				next.options.length = 1; // remove all in next object					
				var nextShadow = thisObj._sNext._shadow;
				if(thisObj.selectedIndex > 0){								
					for(var i=0; i<nextShadow.options.length; i++){
						if(nextShadow.options[i].title == selectedValue){
							var tmpOpt = document.createElement("OPTION");								
							tmpOpt.value = nextShadow.options[i].value;
							tmpOpt.text = nextShadow.options[i].text;
							tmpOpt.title = nextShadow.options[i].title;
							tmpOpt.selected = nextShadow.options[i].selected;							
							next.options.add(tmpOpt);
						}
					}								
				}
				CE.fireEventListener(next, "change");
			}	
		}
		var args = arguments;
		for(var i=0; i<args.length; i++){
			var _shadow = CE.$clone(args[i], args[i].name + "Shadow", true);		
			_shadow.style.position = "absolute";
			_shadow.style.top = 100;
			_shadow.style.left = 100;
			_shadow.style.display = "none";
			_shadow.disabled = true;
			args[i]._shadow = _shadow;
			if(args[i-1] != undefined){
				args[i]._sPrevious = args[i-1];
			}else{
				args[i]._sPrevious = null;
			}
			if(args[i+1] != undefined){
				args[i]._sNext = args[i+1];
			}else{
				args[i]._sNext = null;
			}
			CE.$append(args[i], _shadow);
			if(i > 0){
				args[i].options.length = 1;
			}
			CE.addEventListener(args[i], "change", selectOnChange);
		}
		CE.fireEventListener(args[0], "change");				
	},				
	$doc : function(){
		var returnObj = null;
		if(CE.browser("IE8")){
			returnObj = document.body;
		}else if(CE.browser("IE7") || CE.browser("IE6") || CE.browser("IE5.5")){
			returnObj = document.body;
		}else{
			returnObj = document.documentElement;			
		}
		return returnObj; 
	},
	createElement : function (tag, attribs, styles, parent) {
		var el = document.createElement(tag);
		if (attribs) CE.setAttribs(el, attribs);
		if (styles) CE.setStyles(el, styles);
		if (parent) parent.appendChild(el);	
		return el;
	},
	setAttribs : function (el, attribs) {
		for (var x in attribs) {
			el[x] = attribs[x];
		}
	},
	setStyles : function (el, styles) {
		for (var x in styles) {
			el.style[x] = styles[x];
		}
	},
	escape : function(str){
		return str;		
	},
	unescape : function(str){
		str = str.toString();
		str = unescape(str);
		str = str.replace(/[+]/g, " ");
		return str;
	},	
/*
CE.createElement("a",
{
	className: "highslide-loading",
	title: CE.loadingTitle,
	href: "javascript:CE.expanders["+ this.key +"].cancelLoading()",
	innerHTML: CE.loadingText			
},
{
	position: "absolute",
	visibility: "hidden"
},
CE.container);
*/
	iframeMask : function(ctr, outerMostObj){
		if(CE.browser("IE6")){
			//CE.setAlpha(outerMostObj, 70);
			var _mask = CE.newObj("iframe", "iframeMask", "iframeMask", "iframeMask");
			_mask.src = "about:blank";
			_mask.style.margin = "0px";
			_mask.style.padding = "0px";
			_mask.style.position = "absolute";
			_mask.style.background = "#FFFFFF";
			_mask.style.border = "0px solid red";
			//_mask.style.border = "1px solid red";
			_mask.style.zIndex = -10;
			_mask.style.width = "100%";
			_mask.style.height = "500px";
			ctr.appendChild(_mask);
			function ctrOnMouseOver(e){
				if(_mask.heightReset == undefined){
					if(outerMostObj.H == null || outerMostObj.H == undefined){
						CE.pty(outerMostObj);
					}
					CE.setHeight(_mask, outerMostObj.H);
					_mask.heightReset = true;
					//CE.alert("ctrOnMouseOver");
				}
			}
			function ctrOnMouseOut(e){
				CE.removeEventListener(ctr, "mouseover", ctrOnMouseOver);
				CE.removeEventListener(ctr, "mouseout", ctrOnMouseOut);
				//CE.alert("ctrOnMouseOut");
			}
			CE.addEventListener(ctr, "mouseover", ctrOnMouseOver);
			CE.addEventListener(ctr, "mouseout", ctrOnMouseOut);			
		}
	},	
	disableRightClick : function(){
		function contextmenuOnclick(){
			return false;	
		}
		CE.addEventListener(document, "contextmenu", contextmenuOnclick);
	},
	documentOnKeyDown : function(e){
		if(typeof STYLE != "undefined") STYLE.changeStyleByKeyPress(e);
		//if(typeof STYLE != "undefined") STYLE.changeFontSizeByKeyPress(e);
		CE.resizeBrowser(e);
		CE.showAllHiddenIframe(e);		
		if(typeof LL != "undefined")
			LL.keyDownActionForLabel(e);
		if(typeof TB != "undefined")
			TB.keyDownActionForTab(e);
		CE.instantKeydown = e.keyCode;		
		if(CE.instantMousedown != null)
			CE.mouseClickToClosePopup(e);
	},
	documentOnKeyUp : function(e){
		CE.instantKeydown = null;
	},	
	instantKeydown : null,
	instantMousedown : null,	
	mouseClickToClosePopup : function(e){
		if(CE.instantKeydown == 67 && CE.instantMousedown == 'left'){
			try{
				CE.close();
			}catch(e){
				//CE.alert("CE.close()");
			}
		}
	},
	documentOnMouseDown : function(e){
		CE.reloadCurrentPage(e);
		CE.instantMousedown = CE.eventButton(e);
		if(CE.instantKeydown != null)		
			CE.mouseClickToClosePopup(e); 
	},
	documentOnMouseUp : function(e){
		CE.instantMousedown = null;
	},	
	hidedIframes : true,
	showAllHiddenIframe : function(e){
		if(e.ctrlKey == true){
			if(e.keyCode == 69){ //e
				var _iframes = document.getElementsByTagName("iframe");
				for(var i=0; i<_iframes.length; i++){
					if(_iframes[i].style.position == "absolute"){
						_iframes[i].style.top = (this.hidedIframes) ? eval(i+1)*100 +"px" : -10000 +"px";
						_iframes[i].style.left = (this.hidedIframes) ? 100 +"px" : -10000 +"px";
						_iframes[i].style.height = 98 + "px";
						_iframes[i].style.width = 298 + "px";
					}
				}
				this.hidedIframes = !this.hidedIframes;
			}
		}
	},
	reloadCurrentPage : function(e){
		//ctrlKey, altKey, shiftKey
		if(e.ctrlKey == true){			
			var btnCode = CE.eventButton(e);
			if(btnCode == "right"){
				window.location.reload();
				//window.location = "view-source:" + window.location.href ;
			}
		}		
	},
	eventButton : function(e){
		if(CE.browser("IE")){
			if(e.button == 1){
				return "left";
			}else if(e.button == 2){
				return "right";
			}else if(e.button == 3){
				return "leftright";
			}else if(e.button == 4){
				return "middle";
			}else if(e.button == 5){
				return "leftmiddle";
			}else if(e.button == 6){
				return "middleright";
			}else if(e.button == 7){
				return "leftmiddleright";
			}
		}else{
			if(e.button == 0){
				return "left";			
			}else if(e.button == 1){
				return "middle";
			}else if(e.button == 2){
				return "right";
			}
		}
	},
	browerSize : null,
	resizeBrowser : function(e){
		var windowBorder = 1;
		var windowTitleHeight = 24;
		var windowXpBorderOffset = 6;	
		
		//ctrlKey, altKey, shiftKey
		if(e.altKey == true){
			if(e.keyCode == 123){
				var scn = CE.scnPty();			
				if(CE.browerSize == null){
					window.resizeTo(800,570);
					CE.browerSize = "800x600";
					window.moveTo((scn.W-800)/2, (scn.H-570)/2);
				}else if(CE.browerSize == "800x600"){
					window.resizeTo(1032,746);					
					CE.browerSize = "1024x768";
					window.moveTo((scn.W-1032)/2, (scn.H-746)/2);
				}else if(CE.browerSize == "1024x768"){
					//to max.
					window.resizeTo(scn.W-windowBorder, scn.H-windowBorder);
					CE.browerSize = null;
					window.moveTo(0, 0);
				}
			}
		}
	},
	browser : function(sType){
		// sType = IE, IE4, IE5, IE6, FF, Mac, Opera, NS, NS4, DOM, GC
		var _ub = window.navigator.userAgent.toUpperCase();
//CE.alert(_ub);
//alert("GC="+CE.browser("GC") + ",SAFARI="+CE.browser("SAFARI") + ",OPERA="+CE.browser("OPERA") + ",FF="+CE.browser("FF") + ",IE8="+CE.browser("IE8"));
		switch(sType){
			case "DOM":
				return (document.getElementById) ? true : false;
				break;
			case "IE":
				return (_ub.indexOf("MSIE") != -1) ? true : false;
				break;
			case "IE5":
				return (_ub.indexOf("MSIE 5.5") != -1 && (_ub.indexOf("MSIE 6.0") == -1) && (_ub.indexOf("MSIE 7.0") == -1) && (_ub.indexOf("MSIE 8.0") == -1)) ? true : false;
				break;
			case "IE6":
				return ((_ub.indexOf("MSIE 6.0") != -1) && (_ub.indexOf("MSIE 7.0") == -1) && (_ub.indexOf("MSIE 8.0") == -1) ) ? true : false;
				break;
			case "IE7":
				return (_ub.indexOf("MSIE 7.0") != -1) ? true : false;
				break;
			case "IE8":
				return (_ub.indexOf("MSIE 8.0") != -1) ? true : false;
				break;
			case "FF":
				return (_ub.indexOf("FIREFOX") != -1) ? true : false;
				break;				
			case "NS":
				return (_ub.indexOf("NETSCAPE") != -1) ? true : false;
				break;		
			case "SAFARI":
				return (_ub.indexOf("SAFARI") != -1 && _ub.indexOf("CHROME") == -1) ? true : false;
				break;		
			case "OPERA":
				return (_ub.indexOf("OPERA") != -1) ? true : false;
				break;
			case "GC":
				return (_ub.indexOf("CHROME/") != -1) ? true : false;
				break;
			default:
				return false;			
			 break;
		}
	}, 
	scrolBarW : function(){
		return 17;
	},
	addClassName : function(el, className){
		el.className = (el.className != "") ? el.className + " " + className : className;
	},
	objType : function(obj){
		var type = null;		
		if(obj.tagName.toLowerCase() == "select"){
			type = "select";
		}else if(obj.tagName.toLowerCase() == "textarea"){
			type = "textarea";
		}else if(obj.tagName.toLowerCase() == "input"){
			type = "input";			
			if(obj.type.toLowerCase() == "radio"){
				type = "radio";
			}else if(obj.type.toLowerCase() == "checkbox"){
				type = "checkbox";
			}else if(obj.type.toLowerCase() == "label"){
				type = "label";
			}else if(obj.type.toLowerCase() == "file"){
				type = "file";
			}else if(obj.type.toLowerCase() == "button"){
				type = "button";
			}else if(obj.type.toLowerCase() == "submit"){
				type = "submit";
			}else if(obj.type.toLowerCase() == "reset"){
				type = "reset";
			}else if(obj.type.toLowerCase() == "hidden"){
				type = "hidden";
			}else if(obj.type.toLowerCase() == "password"){
				type = "password";
			}
		}
		return type;
	},
	replaceAll : function(txt, form, to){
 		var t = txt.toString();
		var re = new RegExp (form, "g");
		t = t.replace(re, to);		
		return t;
	},
	trim : function(txt){
		var t = new String();
		t = txt;
		while(t.substr(0,1) == " "){
			t = t.substr(1, t.length);
		}
		while(t.substr(t.length-1,1) == " "){
			t = t.substr(0, t.length-1);
		}		
		return t;
	},
	isInteger : function(txt){
		var ok = false;
		ok = this.isNumber(txt);
		if(ok){
			var t = new String();
			t = txt;
			var re = /[^0-9]/;   //not digit
			ok = t.match(re);
			ok = (ok == null) ? true : false;			
		}
		return ok;
	},
	isNumber : function(txt){
		var ok = false;
		if(txt == ""){
			ok = false;
		}else{
			var t = new String();
			t = txt;
			var re = /[^0-9.-]/;   //not digit
			ok = t.match(re);
			ok = (ok == null) ? true : false;
			if(ok)
				ok = isFinite(txt);		
			if(ok){
				if(isNaN(txt))
					ok = false;
			}
		}
		return ok;
	},
	select : function(obj, valueType, value){
		var objType = this.objType(obj);
		if(objType == "select"){
			for(var i=0; i<obj.options.length; i++){
				if(valueType == "text"){				
					if(obj.options[i].text == value){
						obj.options[i].selected = true;
					}else{
						obj.options[i].selected = false;
					}
				}else if(valueType == "value"){
					if(obj.options[i].value == value){
						obj.options[i].selected = true;
					}else{
						obj.options[i].selected = false;
					}
				}			
			}
		}		
	},

	resizeEnd : function(){
//		window.location.reload();
	},
	docPty : function(){	// document width/height
		var p = new Object();
		p.W = document.documentElement.clientWidth;	
		p.H = document.documentElement.clientHeight; 
		p.sW = document.documentElement.scrollWidth;	
		p.sH = document.documentElement.scrollHeight; 
		var doc = null;
		if(CE.browser('IE6') || CE.browser('GC') || CE.browser('SAFARI')){
			//CE.alert("document.body");			
			doc = document.body;
		}else{
			//CE.alert("document.documentElement");
			doc = document.documentElement;			
		}
		p.sT = doc.scrollTop;	
		p.sL = doc.scrollLeft; 
		//CE.alert("docPty=(scrollTop="+p.sT +", scrollLeft="+p.sL+")");
		//alert("docPty=("+p.W +", "+p.H+")");
		return p;	
	},
	winPty : function(){	// window width/height
		var p = new Object();
		p.W = window.scravailWidth;	
		p.H = window.clientHeight; 
		//alert("winPty=("+p.W +", "+p.H+")");
		return p;	
	},
	scnPty : function(){	
		var p = new Object();
		var w = null;
		var h = null;		
		if(!CE.browser("IE")){
			w = screen.width;
			h = screen.height - 60; 
		}else{
			w = screen.AvailWidth;
			h = screen.AvailHeight;	
		}
//		CE.alert(w +"_"+ h);
		p.W = w;	
		p.H = h; 
		return p;	
	},
	newObj : function(tagName, id, name, className, k){
		tagName = tagName.toLowerCase();
		var _el = document.createElement(tagName);
		if(id != undefined)		
			_el.id = id; 
		if(name != undefined)		
			_el.name = name; 
		if(className != undefined)					
			_el.className = className;
		if(k != undefined)
			_el.k = k;
		if(tagName == "table"){
			_el.cellPadding = 0;
			_el.cellSpacing = 0;			
			_el.border = 0;
//			_el.id = id + "_" + k;
		}
		if(tagName == "iframe"){
			_el.frameBorder = "0";
			//_el.src = "about:blank";
			//_el.allowTransparency = "0";
		}
		if(tagName == "img"){
			_el.src = CE.basePath + "/images/spacer.gif";
		}
		if(tagName == "iframe" && k != undefined){ 
//			_el.name = tagName + "_" + k ; //name
		}
		return _el;
	},
	event : function(e){
		if (!e) e = window.event;
		return e;	
	},	
	preventDefault : function(e){
		//to cancel any default action for the event.
		if(!CE.browser("IE")){	
			e.preventDefault();		
		}else{
			e.returnValue = false;				
		}
		return e;
	},
	stopPropagation : function(e){
		//prevent the event from bubbling.
		if(!CE.browser("IE")){	
			e.stopPropagation();
		}else{
			e.cancelBubble = true;
		}
		return e;
	},	
	eventObj : function(e){
		if (!e) e = window.event;		
		if (e.button > 1) return false;
		if (!e.target) e.target = e.srcElement;		
		var thisObj = e.target;				
		
		if(thisObj.tagName == undefined) return false;
		if(thisObj.tagName.match(/(FORM|HTML|BODY)/)) return false;
		
		return e.target;		
	},
	aniBox : function(){
		if(document.getElementById("aniBox") == undefined){ 
			var _obj = CE.newObj("div", "aniBox", "aniBox", "aniBox", 0);
			_obj.style.position = "absolute";
			_obj.style.top = "-1000px";			
			_obj.style.left = "-1000px"; 
			document.body.appendChild(_obj);   
		}else{
			var _obj = document.getElementById("aniBox");
		}
		return  _obj;
	},
	txtWidth : function(str, className){		
		if(this.txtDmyDiv == null){
			var _tmpDiv = CE.newObj("div", "txtDmyDiv", "txtDmyDiv", "txtDmyDiv", 1);
			_tmpDiv.style.whiteSpace = "nowrap";
			_tmpDiv.style.padding = "0px";
			_tmpDiv.style.border = "1px solid red";
			_tmpDiv.style.position = "absolute";
			_tmpDiv.style.top = "-1000px";
			_tmpDiv.style.left = "-1000px";			
			document.body.appendChild(_tmpDiv);
			this.txtDmyDiv = _tmpDiv;
		}
		
		if(className != undefined)
			this.txtDmyDiv.className  = className + "txtDmyDiv";
			
		this.txtDmyDiv.innerHTML = str;
		CE.pty(this.txtDmyDiv);	
		return this.txtDmyDiv.W;
	},
	winMask : function(){
		if(!document.getElementById("winMask")){
			var _obj = CE.newObj("div", "winMask", "winMask", "winMask", 0);
			_obj.style.top = "0px";
			_obj.style.left = "0px";			
			_obj.style.width = CE.docPty().W + "px";
			_obj.style.height = CE.docPty().H + "px";	
			document.body.appendChild(_obj);
		}else{
			var _obj = document.getElementById("winMask");
		}
		this.toZIndex = function(z){

			_obj.style.zIndex = z;
		}		
		this.toTop = function(){
			_obj.style.zIndex = "9998";
		}
		this.toBottom = function(){
			_obj.style.zIndex = "1";			
		}
		this.front = function(){		
			_obj.style.zIndex = _obj.style.zIndex + 1;
		}
		this.back = function(){		
			_obj.style.zIndex = _obj.style.zIndex - 1;			
		}
		this.on = function(){		
			_obj.style.visibility = "visible";
			_obj.style.width = document.documentElement.scrollWidth + "px";
			_obj.style.height = document.documentElement.scrollHeight + "px";	
		}		
		this.off = function(){
			_obj.style.visibility = "hidden";
		}
		_obj.onclick = function(){
			return false;	
		}
		return this;
	},
	copyPty : function(from, to){
		to.A = from.A;
		to.X = from.X;
		to.Y = from.Y;
		to.W = from.W;
		to.H = from.H;
		
		to.preA = from.preA;
		to.preX = from.preX;
		to.preY = from.preY;
		to.preW = from.preW;
		to.preH = from.preH;
	},
	pty : function(el, checkFlag){
		// el must be appended to document		
		var parent = el;
		var p = new Object();
//		var tinyOffset = ((CE.browser("IE")) ? 2 : 0);
		var tinyOffset = 0;		
		p.x = parent.offsetLeft - tinyOffset;
		p.y = parent.offsetTop - tinyOffset;
		while (parent.offsetParent){ // offsetParent, set all div.style.positive = "absolute"		
			parent = parent.offsetParent;
//			CE.alert(parent.tagName +"_"+ parent.id +"_"+ parent.clientTop);
			if(parent.scrollLeft != 0){ //IE
				if(parent.tagName.toLowerCase() == "html" || parent.tagName.toLowerCase() == "body"){
					// do nothing
				}else{
					p.x -= parent.scrollLeft;
				}
			}
//			CE.alert(parent.tagName + parent.style.left);
			p.x += parent.offsetLeft; //has set absolute .left
			p.y += parent.offsetTop; //has set absolute .top
			p.x += parent.clientLeft;
			p.y += parent.clientTop;			
		}
 		el.X = parseFloat(p.x);
		el.Y = parseFloat(p.y);
		//tommy
		//clienWidth = width + padding
		//offsetWidth = width + padding + border
		//clientLeft = magin + border
		//offsetLeft = width + padding + border
		
		//CE.alert(el.clientWidth +"_"+ el.offsetWidth +"_"+ el.clientLeft);
		//CE.alert(el.clientWidth + "_" + el.width + "_" +  el.offsetWidth + "_" + el.tagName + "_" +  el.style.paddingLeft);		
		//el.W = parseFloat(el.clientWidth - el.clientLeft); // including border width;		
		
		//user > clientWidth > tab.js not work
		el.W = parseFloat(el.offsetWidth);		
		//el.W = parseFloat(el.clientWidth);
		el.H = parseFloat(el.offsetHeight);
		//el.H = parseFloat(el.clientHeight);

		if(!CE.browser("IE")){
			var a = el.style.opacity;
		}else{
			var a = el.style.filter;
			a = a.replace("alpha(opacity=", "");
			a = a.replace(")", "");			
			a = a/100;
		}
		el.A = (a == "") ? 1 : a;
		el.L = (el.scrollLeft == undefined) ? 0 : el.scrollLeft;
		el.T = (el.scrollTop == undefined) ? 0 : el.scrollTop;		

		el.preA = (el.preA == undefined) ? null : el.preA;
		el.preX = (el.preX == undefined) ? null : el.preX;
		el.preY = (el.preY == undefined) ? null : el.preY;
		el.preW = (el.preW == undefined) ? null : el.preW;
		el.preH = (el.preH == undefined) ? null : el.preH;
		el.preL = (el.preL == undefined) ? null : el.preL;
		el.preT = (el.preT == undefined) ? null : el.preT;
		
		return el;
	},
	setAlpha : function(el, value){
		//value = 0-1
		el.style.opacity = value/100;
		el.style.filter = "alpha(opacity="+value+")";
	},
	setWidth : function(el, value){
		var _offset = 0;
		if(el.padding != undefined)
			_offset = el.padding;
		el.style.width = eval(value - _offset*2) + "px";
	},	
	setHeight : function(el, value){
		var _offset = 0;
		if(el.padding != undefined)
			_offset = el.padding;
		el.style.height = eval(value - _offset*2) + "px";
	},	
	setTop : function(el, value){
		el.style.top = value + "px";
	},	
	setLeft : function(el, value){
		el.style.left = value + "px";
	},	
	setPty : function(obj, _current, _previous, _from){
		if(_current == undefined){
			CE.pty(obj);
		}		
		if(_current != undefined && _current != ""){
			obj.X = parseFloat(_current[0]);
			obj.Y = parseFloat(_current[1]);
			obj.W = parseFloat(_current[2]);
			obj.H = parseFloat(_current[3]);
			obj.A = (_current[4] == undefined) ? 1 : _current[4];
		}		
		if(_previous != undefined && _previous != ""){
			obj.preX = parseFloat(_previous[0]);
			obj.preY = parseFloat(_previous[1]);
			obj.preW = parseFloat(_previous[2]);
			obj.preH = parseFloat(_previous[3]);
			obj.preA = (_previous[4] == undefined) ? 1 : _previous[4];	
		}
		if(_from != undefined && _from != ""){
			obj.fromX = parseFloat(_from[0]);
			obj.fromY = parseFloat(_from[1]);
			obj.fromW = parseFloat(_from[2]);
			obj.fromH = parseFloat(_from[3]);
			obj.fromA = (_from[4] == undefined) ? 1 : _from[4];
		}
	},	
	confirm : function(e, msg){
		var cont = null;
		var textObj = null;
		var yesBtn = null;
		var noBtn = null;
		alert(this.id);
		this.returnAction = function(){
			alert("this.returnAction");
		}		
		function closeConfirm(_evt){
			var _thisObj = CE.eventObj(_evt);
			var lower = CE.getParentByClassName(_thisObj, "lower");
			cont.style.display = "none";
			PU.closePopUp(lower.k);
			this.returnAction();
		}
		if(CE.$("cont") == null){
			cont = CE.newObj("div", "cont", "cont", "cont");			
			textObj = CE.newObj("label", "textObj", "textObj", "textObj");
			yesBtn = CE.newObj("input", "yesBtn", "yesBtn", "yesBtn");			
			yesBtn.type = "button";
			yesBtn.value = "Yes";
			noBtn = CE.newObj("input", "noBtn", "noBtn", "noBtn");			
			noBtn.type = "button";
			noBtn.value = "No";
			CE.addEventListener(noBtn, "click", closeConfirm);
			cont.style.display = "none";
			cont.style.border = "1px solid red";
			cont.appendChild(textObj);
			cont.appendChild(yesBtn);
			cont.appendChild(noBtn);
			document.body.appendChild(cont);
		}else{
			cont = CE.$("cont");
			textObj = CE.$("textObj");
		}
		textObj.innerText = msg;
		window.popup(e, cont, "width:400;height:100;closeButton:false;maxButton:false");
		cont.style.display = "";
		this.returnValue = "fffff";

		return this.returnValue;
	},
	alert : function(errStr, maxRow){		
		if(this.errorBox == null){
			var errDiv = document.createElement("div");
			errDiv.style.border = "1px solid red";
			errDiv.style.position = "absolute";
			errDiv.style.fontSize = "12px";
			errDiv.style.top = "10px";
			errDiv.style.left = "700px";
			errDiv.style.width = "300px";
			errDiv.style.height = "200px";		
			errDiv.style.overFlow = "scroll";
			errDiv.style.display = "";
			errDiv.style.background = "#FFFFFF";
			CE.addEventListener(errDiv, "click", 
				function hiddenErrorBox(){
					errDiv.style.display = "none";
				}
			);
			document.body.appendChild(errDiv);
			this.errorBox = errDiv;					
		}
		if(maxRow != undefined){
			if(this.errCount % maxRow == 0)
				this.errorBox.innerHTML = "";
		}
		this.errorBox.style.display = "";
		this.errorBox.innerHTML = this.errorBox.innerHTML + ((this.errCount==0) ? "" : " <br/> ") + " (" + this.errCount + ") > " + errStr ;
		this.errCount++;
	},
	alertPty : function(obj){
		var str = "X = " + obj.X + "<br/>" + 
		"Y = " + obj.Y + "<br/>" + 
		"W = " + obj.W + "<br/>" + 
		"H = " + obj.H + "<br/>" + 
		"A = " + obj.A + "<br/>" + 
		"preX = " + obj.preX + "<br/>" + 
		"preY = " + obj.preY + "<br/>" + 
		"preW = " + obj.preW + "<br/>" + 
		"preH = " + obj.preH + "<br/>" + 
		"preA = " + obj.preA + "<br/>" + 		
		"fromX = " + obj.fromX + "<br/>" + 
		"fromY = " + obj.fromY + "<br/>" + 
		"fromW = " + obj.fromW + "<br/>" + 
		"fromH = " + obj.fromH + "<br/>" + 
		"fromA = " + obj.fromA + "<br/>";	
		CE.alert(str);
	},
	LIs : function(ul){		// <ul> , <li>		
		var LIs = ul.childNodes;		
		var liAry = new Array();
		for(var i=0; i<LIs.length; i++){
			if(LIs[i].nodeType != 3 && LIs[i].nodeType != 8){ // select li object	
				liAry.push(LIs[i]);
			}
		}
		return liAry;
	},
	selected : function(obj, valueType){
		var objType = this.objType(obj);
		if(objType == "select"){
			if(valueType == "text"){				
				return obj[obj.selectedIndex].text;
			}else if(valueType == "value"){
				return obj[obj.selectedIndex].value;
			}
		}else if(objType == "radio"){
			var _name = obj.name;
			var _radios = CE.getElementsByName(document, "input", _name);
			for(var i=0; i<_radios.length; i++){
				if(_radios[i].checked == true){
					if(valueType == "value"){				
						return _radios[i].value;
					}else if(valueType == "text"){
					}else{
						return null; 
					}
					break;
				}
			}
			return null;
		}else if(objType == "checkbox"){
			var _name = obj.name;
			var retAry = new Array();
			var _checks = CE.getElementsByName(document, "input", _name);
			if(_checks.length != undefined){
				for(var i=0; i<_checks.length; i++){
					if(_checks[i].checked == true){
						if(valueType == "value"){
							retAry.push(_checks[i].value);
						}else if(valueType == "text"){
							var _text = CE.getParentByTagName(_checks[i], "label");
						}else if(valueType == "object"){							
						}else{
							return null; 
						}
					}
				}
			}
			return retAry;			
		}
	},
	getElementsByName : function(base, tag, name, exactName){	
		var tags = base.getElementsByTagName(tag);
		var objs = new Array();
		for(var i=0; i<tags.length; i++){
			if(exactName == undefined || exactName == false){
				if(tags[i].name.indexOf(name) != -1){
					objs.push(tags[i]);	
				}
			}else if(exactName == true){
				if(tags[i].name == name){
					objs.push(tags[i]);	
				}
			}
		}		
		return objs;	
	},
	getElementsByClassName : function(base, tag, className, exactClassName){
		var tags = base.getElementsByTagName(tag);
		var objs = new Array();
		for(var i=0; i<tags.length; i++){
			if(exactClassName == undefined || exactClassName == false){
				if(tags[i].className.indexOf(className) != -1){
					objs.push(tags[i]);	
				}
			}else if(exactClassName == true){
				if(tags[i].className == className){
					objs.push(tags[i]);	
				}
			}
		}		
		return objs;
	},	
	getParentByClassName : function(obj, className, exactClassName){
		while(obj.parentNode != undefined && 
			  (
			   (obj.className.indexOf(className) == -1 && (exactClassName == false || exactClassName == undefined) ) ||
			   (obj.className != className && exactClassName == true)
			  )
			){
			obj = obj.parentNode;			
		}
		return obj;
	},
	getParentByTagName : function(obj, tagName){
		while(obj.parentNode != undefined && (obj.tagName.toLowerCase() != tagName.toLowerCase())){
			obj = obj.parentNode;			
		}
		return obj;
	},
	//CE.addEventListener(document, "click", this.documentOnClick);	
	addEventListener : function (el, event, func) {
		if (document.addEventListener) el.addEventListener(event, func, false);
		else if (document.attachEvent) el.attachEvent("on"+ event, func);
		else el["on"+ event] = func;
	},
	//CE.removeEventListener(document, "click", this.documentOnClick);	
	removeEventListener : function (el, event, func) {
		if (document.removeEventListener) el.removeEventListener(event, func, false);
		else if (document.detachEvent) el.detachEvent("on"+ event, func);
		else el["on"+ event] = null;
	},
	//.click()
	fireClick : function (el) {
		if(CE.browser("IE")){
			el.click();
		}else{
			var evtObj = document.createEvent("MouseEvents");     
			evtObj.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, true, false, 0, null);
			el.dispatchEvent(evtObj);	
		}
	},	
	/*
	bFired = object.fireEvent(sEvent [, oEventObject])
	http://msdn.microsoft.com/en-us/library/ms536423(VS.85).aspx
	*/
	fireEventListener : function (el, event) {
		if(CE.browser("IE")){
			el.fireEvent("on"+ event);
		}else{
			var evtObj = document.createEvent("MouseEvents");     
			evtObj.initMouseEvent(event, true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, true, false, 0, null);
			el.dispatchEvent(evtObj);	
		}
	},		
	onReadyStateChange : function (el, func) {	
		//function frameOnReadyStateChange(el){
		//		var thisObj = el;
		//}	
		//CE.onReadyStateChange(_iframe, frameOnReadyStateChange);
		
		el.onreadystatechange =function(){  
			if(el.readyState){
				if(el.readyState=="complete"){
					if(!el.loadedByUserAction){
						//alert("IE onReadyStateChange_loaded")
						func(el);
						el.loadedByUserAction = true;
					}
				}
			}else{
				if(!el.loadedByUserAction){				
					//alert("FF onReadyStateChange_loaded");
					func(el);
					el.loadedByUserAction = true;
				}
			}
		}
		if (!CE.browser("IE")){ 
			el.onload =function(){  
				this.onreadystatechange.apply(this);
			}
		}
	},
	getFormElementsInObject : function(obj){
		var elType = ["input", "select", "textarea"];
		var els = new Array();
		for(var i=0; i<elType.length; i++){
			var tmpEls = obj.getElementsByTagName(elType[i]);
			for(var j=0; j<tmpEls.length; j++){
				els.push(tmpEls[j]);
			}
		}
		return els;
	},
	disableElementsInObject : function(disable, obj){
		var els = CE.getFormElementsInObject(obj);
		for(var i=0; i<els.length; i++){
			els[i].disabled = disable;
		}		
	},
	pmrsToArray : function(str){
		//"header:true;footer:true;leftmenu:true;"
		// to array
		var ary = new Array();
		var pmrs = str.split(";");
		for(var i=0; i<pmrs.length; i++){
			ary.push(pmrs[i].split(":"));
		}		
		return ary;
	},				
/* -------------------------- Cookie --------------------------------- */
	setCookie : function(name, value, expires, path, domain, secure){
		if(expires == undefined){
			var expires = new Date();
			expires.setTime(expires.getTime() + 3 * 30 * 24 * 60 * 60 * 1000);
		}
		//3 months
		document.cookie = name + "=" + escape(value) +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
	},
	getCookie : function(name){
	    var dc = document.cookie;
	    var prefix = name + "=";
	    var begin = dc.indexOf("; " + prefix);
		if (begin == -1){
			begin = dc.indexOf(prefix);
			if (begin != 0) return null;
		}else{
			begin += 2;
		}		
	    var end = document.cookie.indexOf(";", begin);
	    if (end == -1){
    	    end = dc.length;
	    }
    	return unescape(dc.substring(begin + prefix.length, end));
	},
	deleteCookie : function(name, path, domain){
	    if (this.getCookie(name)){
    	    document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	    }
	},
/* -------------------------- Cookie --------------------------------- */
/* -------------------------- Editable Hidden Field ------------------ */
	labelToEdit : function(theLabel){
		function changeMode(e){
			var thisObj = CE.eventObj(e);
			var thisLabel = thisObj.parentNode;
			var thisParent = thisObj.parentNode.parentNode;
			var thisFont = CE.$s(thisLabel, "font")[0];
			thisFont.style.display = "none";			
			var thisHiddenfield = CE.$s(thisLabel, "input")[0];
			var _textField = null;
			var _textType = null;
			/*
			if(thisParent.tagName.toUpperCase() == "TD"){
				_textField = CE.newObj("textarea", "textField", "textField", "textField");
				_textField.style.overflow = "auto";
				_textField.style.width = "100%";
				_textField.style.height = thisParent.clientHeight - 10 + "px";
			}else{
			*/
				_textField = CE.newObj("input", "textField", "textField", "textField");
				_textField.type = "text";
				_textType = "text";
			//}
			_textField.style.border = "0px solid red";
			_textField.style.background = "transparent";
			_textField.style.padding = "0px";
			_textField.value = thisHiddenfield.value;
			thisLabel.appendChild(_textField);
			_textField.focus();
			_textField.select();
			if(_textType == "text")
				CE.addEventListener(_textField, "keydown", textFieldOnKeyDown);
			CE.addEventListener(_textField, "blur", textFieldOnBlur);

			CE.removeEventListener(thisLabel, "click", changeMode);			
		}		
		function returnAction(thisObj){
			var thisLabel = thisObj.parentNode;
			var thisParent = thisObj.parentNode.parentNode;
			var thisFont = CE.$s(thisLabel, "font")[0];
			var thisHiddenfield = CE.$s(thisLabel, "input")[0];
			thisHiddenfield.value = thisObj.value;
			thisFont.innerHTML = thisObj.value;
			thisFont.style.display = "";
			thisLabel.removeChild(thisObj);			
			CE.addEventListener(thisLabel, "click", changeMode);
		}
		function textFieldOnKeyDown(e){
			var thisObj = CE.eventObj(e);
			if(e.keyCode == 13){ 
				returnAction(thisObj);
			}
		}		
		function textFieldOnBlur(e){
			var thisObj = CE.eventObj(e);
			returnAction(thisObj);
		}	
		function fontOnMouseOver(e){
			var thisObj = CE.eventObj(e);
			thisObj.style.background = "#FFFF00";
		}		
		function fontOnMouseOut(e){
			var thisObj = CE.eventObj(e);
			thisObj.style.background = "";			
			
		}		
		var _hiddenfield = CE.$s(theLabel, "input")[0];
		if(CE.$s(theLabel, "font")[0] != undefined){
			var _font = CE.$s(theLabel, "font")[0];
			if(!CE.browser("IE")){
				CE.addEventListener(_font, "mouseover", fontOnMouseOver);
				CE.addEventListener(_font, "mouseout", fontOnMouseOut);					
				CE.addEventListener(theLabel, "click", changeMode);
			}
		}else{
			var _font = CE.newObj("font", "hiddenfont", "hiddenfont", "hiddenfont");	
			theLabel.appendChild(_font);			
			CE.addEventListener(_font, "mouseover", fontOnMouseOver);
			CE.addEventListener(_font, "mouseout", fontOnMouseOut);					
			CE.addEventListener(theLabel, "click", changeMode);			
		}
		_font.innerHTML = _hiddenfield.value;
		_font.style.cursor = "pointer";
		
	},
 	hiddenfields : new Array(),	
	transformHiddenField : function(base){
		var _span = CE.$s(base, "span");
		for(var i=0; i<_span.length; i++){
			var _inputs = CE.$s(_span[i], "input");
			if(_inputs.length > 0){
				CE.labelToEdit(_span[i]);
				CE.hiddenfields.push(_span[i]);
			}
		}
		/*
		for(var i=0; i<CE.hiddenfields.length; i++){
			CE.labelToEdit(CE.hiddenfields[i]);
		}
		*/		
	}, 
	getFile : function(n){
		var file; // Define variable
		if( n == ''|| n == self.location)
			return []; 
			// Don't request self or empty strings (Safety meassure for some IE and pre0.9.9 Moz versions)
		switch(typeof ActiveXObject){
			case 'function' : // Check if ie
			file = new ActiveXObject('Microsoft.XMLHTTP'); // If so use ie XHreq
			break;
		default:
			file = new XMLHttpRequest; // Otherwise use moz XHreq 
			file.overrideMimeType("text/xml"); // And override content-type to avoid breakage
		}
		try{ // Error susceptible code (Moz may screw up, especially if you're breaking the security rules)
			file.open('GET', n, false); // Open connection
			file.send('') // Send empty string
		}catch(e){ // If error
			return [] // ...return empty null-length array
		} 
		//return [file.responseText, file.getAllResponseHeaders()] 
		return [file.responseText] 
		// Otherwise return response and http headers
	}, 
	initContextPath : function(){
		var basePathInCookie = CE.getCookie("basePath");
		if(basePathInCookie == null){
			var _contextPath = CE.contextPath();
			if(_contextPath != null){
				//CE.alert("no basePathInCookie" + basePathInCookie);								
				CE.setCookie("basePath", _contextPath);
				basePathInCookie = _contextPath;
			}			
		}else{
			//CE.alert("have basePathInCookie" + basePathInCookie);
		}
		this.basePath = basePathInCookie;
	}, 
	contextPath : function(){
		var _pointerFile = "js/core.js";
		var _curPath = window.location.toString();
		_curPath = _curPath.substr(0,_curPath.lastIndexOf("/"));
		var _flag = true; 
		//CE.alert(this.getFile(_curPath + "/" + _pointerFile).toString().substr(0, 23));
		while(this.getFile(_curPath + "/" + _pointerFile).toString().substr(0, 23) != "//don't delete this row"){
			if(_curPath.indexOf("/") == -1){
				_flag = false;
				break;
			}
			_curPath = _curPath.substr(0,_curPath.lastIndexOf("/"));
		}
		if(_flag){
			return _curPath;
		}else{
			return null;
		}

	},
/* -------------------------- Editable Hidden Field ------------------ */
/* -------------------------- animation ------------------------------ */	
	hide :function(_obj){
		_obj.style.position = "absolute";
		_obj.style.top = "-1000px";
		_obj.style.left = "-1000px";
	},
/* -------------------------- animation ----------------------------- */		
/* -------------------------- popup --------------------------------- */		
	close : function(){
		var _window = window.parent;
		var _this = window.frameElement;
		_window.PU.closePopUp(_this.k); 
	},
	returnValue : function(_value){
		var _window = window.parent;
		var _this = window.frameElement;
		_window.PU.returnValueToFromObject(_this.k, _value); 
	},
	removeValue : function(thisObj){ 
		PU.removeValueFromObject(thisObj); 
	}
/* -------------------------- popup --------------------------------- */
}

CE.init();

/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------- End ------------------------------------- */
/* -------------------------- Core Function ----------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
 
 
 
  
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- Start ------------------------------------- */
/*AN ------------------------ Animation Engine--------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
 
/* -------- sample---------------------------------------------------------	
	["x", "y", "width", "height", "alpha"]
	
	function Tween(object, property, easing, begin, finish, duration, useSeconds, loop){
	}
	
	var _tween = Tween(el, "x", Strong.easeOut, 100, 200, 20, false);
	_tween.addEventListener("MOTION_FINISH", _tweenCompleted);
	function _tweenCompleted(){
		alert("_tweenCompleted");
	}
	
	AN.backward(document.getElementById('objA'), Strong.easeOut, 20);
	AN.backwardAt(document.getElementById('objA'), 'y', Strong.easeOut, 20);	
*/

var AN = {
	id : "AN",
	tweens : new Array(),
	init : function(){
		if(typeof CG != "undefined"){
			CG.AN();
		}			
//		CE.addEventListener(document, "mouseup", this.mouseUp);	
	},
	backward : function(el, easing, duration, finishFunc){
		var _tween = null;
		var ptyAry = ["X", "Y", "W", "H", "A"];
		var propertyAry = ["x", "y", "width", "height", "alpha"];
		for(var i=0; i<ptyAry.length; i++){ 
			if(eval("el.pre"+ptyAry[i].toUpperCase()) != null){  //pre pty is changed.
			_tween = Tween(el, propertyAry[i], easing, eval("el."+ptyAry[i]), eval("el.pre"+ptyAry[i]));
			}
		}
		if(_tween != null && finishFunc != undefined){
			_tween.addEventListener("MOTION_FINISH", _tweenBackwardCompleted);
		}
		function _tweenBackwardCompleted(){
			finishFunc();
		}
	},
	backwardAt : function(el, property, easing, duration){
		var pty = property;		
		if(property == "alpha") pty = "a";
		if(property == "width") pty = "w";
		if(property == "height") pty = "h";	
		CE.pty(el);
		Tween(el, property, easing, eval("el."+pty), eval("el.pre"+pty.toUpperCase()), duration, false);
	},
	transform : function(el, from, to, easing, finishFunc, duration, useSeconds, loop){ 
		var _tween = null;
		var ptyAry = ["x", "y", "z", "width", "height", "alpha"];
		var hasChanged = false;
		for(var i=0; i<ptyAry.length; i++){
			var fromPtyValue = eval("from."+ptyAry[i]);
			var toPtyValue = eval("to."+ptyAry[i]);			
			if(fromPtyValue != toPtyValue){  //pre pty is changed.
				_tween = Tween(el, ptyAry[i], easing, fromPtyValue, toPtyValue, duration, useSeconds);  
				if(hasChanged == false && _tween != null && finishFunc != undefined){
					_tween.addEventListener("MOTION_FINISH", _tweenTransformCompleted);
				}				
				hasChanged = true;
			} 
		} 
		function _tweenTransformCompleted(){
			finishFunc();
		}		
	}, 
	box : function(from, to, easing, finishFunc, duration, useSeconds, loop){
		var _b = CE.aniBox();
		function _completed(){
			_b.style.top = "-1000px";
			_b.style.left = "-1000px";
			finishFunc();
		}
		this.transform(_b, from, to, easing, _completed, duration, useSeconds, loop);
	}
}
var Back = {
	easeOut : { 
		generate : function(minValue, maxValue, totalSteps, actualStep){
			var _actualStep = actualStep;
			var _totalSteps = totalSteps;			
			if(_actualStep > (_totalSteps/2))
				_actualStep = _totalSteps - _actualStep;
			_totalSteps = Math.floor(_totalSteps/2);
			var powr = 5 ;
			var delta = maxValue - minValue; 
			var step = minValue+(Math.pow(((1 / _totalSteps) * _actualStep), powr) * delta); 
			if(_totalSteps == Math.floor(_actualStep)) step = maxValue;						
			if(totalSteps-1 == actualStep) step = minValue;
			return Math.floor(step);
		}, 
		frameRate : 51,
		msecPerFrame : function(){
			return 1000/this.frameRate;
		},
		duration : 15,
		useSeconds : false,		
		steps : function(_useSeconds , _duration){
			if(_duration != undefined)
				this.duration = _duration;	
			if(_useSeconds != undefined)
				this.useSeconds = _useSeconds;	
			return (this.useSeconds) ? this.duration*this.frameRate : this.duration;
		}
	}
}
var Bounce = {
}
var Elastic = {
	easeOut : { 
		generate : function(minValue, maxValue, totalSteps, actualStep){ 
			//animate using Elastic equation 
			clip._x =startX+(distanceX*Math.pow(2,5*(t-1)))*Math.sin(Math.abs(t-a)*-(2*Math.PI)/p);
		}
	}
}
var None = {
	generate : function(minValue, maxValue, totalSteps, actualStep){ 
		var powr = 1;
		var delta = maxValue - minValue; 
		var step = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
		if(totalSteps-1 == actualStep) step = maxValue;
		return step;
	}, 	
	frameRate : 30,
		msecPerFrame : function(){
			return 1000/this.frameRate;
	}, 
	duration : 15,
	useSeconds : false,		
	steps : function(_useSeconds , _duration){
		if(_duration != undefined)
			this.duration = _duration;	
		if(_useSeconds != undefined)
			this.useSeconds = _useSeconds;	
		return (this.useSeconds) ? this.duration*this.frameRate : this.duration;
	}
}
var Regular = {
	easeOut :function(){
	}
}
var Strong = {
	easeOut : { 
		generate : function(minValue, maxValue, totalSteps, actualStep){ 
			var powr = 5 ;
			var delta = maxValue - minValue; 
			var step = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
			if(totalSteps-1 == actualStep) step = maxValue;			
			return step;
		}, 
		frameRate : 30,
		msecPerFrame : function(){
			return 1000/this.frameRate;
		}, 
		duration : 15,
		useSeconds : false,		
		steps : function(_useSeconds , _duration){
			if(_duration != undefined)
				this.duration = _duration;	
			if(_useSeconds != undefined)
				this.useSeconds = _useSeconds;	
			return (this.useSeconds) ? this.duration*this.frameRate : this.duration;
		}
	}
}
var Select = { // for select only
	easeOut : { 
		generate : function(minValue, maxValue, totalSteps, actualStep){
			var powr = 2;
			var delta = maxValue - minValue; 
			var step = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
			if(totalSteps-1 == actualStep) step = maxValue;
			return step;
		}, 
		frameRate : 100,
		msecPerFrame : function(){
			return 1000/this.frameRate;
		}, 
		duration : 15,
		useSeconds : false,		
		steps : function(_useSeconds , _duration){
			if(_duration != undefined)
				this.duration = _duration;	
			if(_useSeconds != undefined)
				this.useSeconds = _useSeconds;	
			return (this.useSeconds) ? this.duration*this.frameRate : this.duration;
		}
	}
}
var List = { // for list only
	easeOut : { 
		generate : function(minValue, maxValue, totalSteps, actualStep){
			var powr = 2;
			var delta = maxValue - minValue; 
			var step = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
			if(totalSteps-1 == actualStep) step = maxValue;
			return step;
		}, 
		frameRate : 50,
		msecPerFrame : function(){
			return 1000/this.frameRate;
		},  
		duration : 15,
		useSeconds : false,		
		steps : function(_useSeconds , _duration){
			if(_duration != undefined)
				this.duration = _duration;	
			if(_useSeconds != undefined)
				this.useSeconds = _useSeconds;	
			return (this.useSeconds) ? this.duration*this.frameRate : this.duration;
		}
	}
}
var Popup = {
	easeOut : { 
		generate : function(minValue, maxValue, totalSteps, actualStep){
			var powr = 0.9; 
			var delta = maxValue - minValue; 
			var step = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
			if(totalSteps-1 == actualStep) step = maxValue;			
			return step;
		}, 
		frameRate : 55,
		msecPerFrame : function(){
			return 1000/this.frameRate;
		}, 
		duration : 15,
		useSeconds : false,		
		steps : function(_useSeconds , _duration){
			if(_duration != undefined)
				this.duration = _duration;	
			if(_useSeconds != undefined)
				this.useSeconds = _useSeconds;	
			return (this.useSeconds) ? this.duration*this.frameRate : this.duration;
		}
	}
}
var Tab = {
	easeOut : { 
		generate : function(minValue, maxValue, totalSteps, actualStep){
			var powr = 1.5; 
			var delta = maxValue - minValue; 
			var step = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
			if(totalSteps-1 == actualStep) step = maxValue;			
			return step;
		}, 
		frameRate : 50,
		msecPerFrame : function(){
			return 1000/this.frameRate;
		}, 
		duration : 15,
		useSeconds : false,		
		steps : function(_useSeconds , _duration){
			if(_duration != undefined)
				this.duration = _duration;	
			if(_useSeconds != undefined)
				this.useSeconds = _useSeconds;	
			return (this.useSeconds) ? this.duration*this.frameRate : this.duration;
		}
	}
}
function TweenObj(){
	this.object = null;
	this.property = null;
	this.easing = null;
	this.begin = null;
	this.finish = null;
	this.duration = null;
	this.useSeconds = null;
	this.loop = null;
	
	this.frameRate = 40;
	this.msecPerFrame = 33.3333;
	this.steps = 20;
	
	this.finishFunction = function(){
		//CE.alert("this.finishFunction");
	}
	this.stepFunction = function(){
		//CE.alert("this.stepFunction");
	}

	this.defaultFinishFunction = function(){
		//CE.alert("this.defaultFinishFunction");
	}
	this.defaultStepFunction = function(){
		//CE.alert("this.defaultStepFunction");
	}	
	this.eventFunction = function(i){
		if(this.steps-1 == i){
			this.defaultFinishFunction();
			this.finishFunction();
		}
		this.defaultStepFunction();							
		this.stepFunction();
	}
	this.alpha = function(value, i){
		//value = 0-1
		this.object.style.opacity = value/100;
		this.object.style.filter = "alpha(opacity="+value+")";
		this.eventFunction(i);
	}
	this.x = function(value, i){
		this.object.style.position = "absolute";
		this.object.style.left = value + "px";
		this.eventFunction(i);		
	}
	this.y = function(value, i){
		this.object.style.position = "absolute";
		this.object.style.top = value + "px";
		this.eventFunction(i);		
	}
	this.width = function(value, i){
		CE.setWidth(this.object, value);
		this.eventFunction(i);		
	}
	this.height = function(value, i){
		this.object.style.height = value + "px";
		this.eventFunction(i);		
	}
	this.scrollLeft = function(value, i){
		this.object.scrollLeft = value;
		this.eventFunction(i);		
	}
	this.scrollTop = function(value, i){
		this.object.scrollTop = value;
		this.eventFunction(i);		
	}
	this.play = function(k){
/*		
		this.frameRate = 30;
		this.msecPerFrame = 1000/this.frameRate;	
		this.steps = (this.useSeconds) ? this.duration*this.frameRate : this.duration;
*/
		this.frameRate = this.easing.frameRate;
		this.msecPerFrame = this.easing.msecPerFrame();

		this.steps = this.easing.steps(this.useSeconds, this.duration);
	
		var delta = 0;
		var pty = this.property.toLowerCase();
		for(var i=0; i<this.steps; i++){
			delta = this.easing.generate(this.begin, this.finish, this.steps, i);			
			if(i == 0){ // previous data to event object
				if(pty == "alpha"){
					this.object.preA = delta/100;
				}else if(pty == "x"){
					this.object.preX = delta;
				}else if(pty == "y"){
					this.object.preY = delta;				
				}else if(pty == "width"){
					this.object.preW = delta;
				}else if(pty == "height"){
					this.object.preH = delta;
				}else if(pty == "scrolleft"){
					this.object.preL = delta;
				}else if(pty == "scroltop"){
					this.object.preT = delta;
				}
			}
			if(i == this.steps-1){ // cur data to event object
				if(pty == "alpha"){
					this.object.A = delta/100;
				}else if(pty == "x"){
					this.object.X = delta;
				}else if(pty == "y"){
					this.object.Y = delta;				
				}else if(pty == "width"){
					this.object.W = delta;
				}else if(pty == "height"){
					this.object.H = delta;
				}else if(pty == "scrollleft"){
					this.object.L = delta;
				}else if(pty == "scrolltop"){
					this.object.T = delta;
				}
			}			
			if(pty == "alpha"){
				setTimeout( "AN.tweens["+k+"].alpha("+delta+", "+i+");", this.msecPerFrame*i);
			}else if(pty == "x"){
				delta = Math.ceil(delta);
				setTimeout( "AN.tweens["+k+"].x("+delta+", "+i+");", this.msecPerFrame*i);			
			}else if(pty == "y"){
				delta = Math.ceil(delta);
				setTimeout( "AN.tweens["+k+"].y("+delta+", "+i+");", this.msecPerFrame*i);			
			}else if(pty == "width"){
				delta = Math.ceil(delta);
				setTimeout( "AN.tweens["+k+"].width("+delta+", "+i+");", this.msecPerFrame*i);			
			}else if(pty == "height"){
				delta = Math.ceil(delta);
				setTimeout( "AN.tweens["+k+"].height("+delta+", "+i+");", this.msecPerFrame*i);			
			}else if(pty == "scrollleft"){
				delta = Math.ceil(delta);
				setTimeout( "AN.tweens["+k+"].scrollLeft("+delta+", "+i+");", this.msecPerFrame*i);			
			}else if(pty == "scrolltop"){
				delta = Math.ceil(delta);
				setTimeout( "AN.tweens["+k+"].scrollTop("+delta+", "+i+");", this.msecPerFrame*i);			
			}
		}
		this.addEventListener("DEFAULT_MOTION_FINISH", _tweenCompleted);
		function _tweenCompleted(){
			if(this.loop)
				this.play(k);			
		}
	}
	this.addEventListener = function(type, func){
		if(type == "DEFAULT_MOTION_FINISH"){
			this.defaultFinishFunction = func;
		}else if(type == "DEFAULT_MOTION_STEP"){
			this.defaultStepFunction = func;
		}else if(type == "MOTION_FINISH"){
			this.finishFunction = func;
		}else if(type == "MOTION_STEP"){
			this.stepFunction = func;			
		}
	}
}
//Tween(this, "x", None, CE.pty(this).x, CE.pty(this).x+400, 50, false);
function Tween(object, property, easing, begin, finish, duration, useSeconds, loop){
	var _tween = new TweenObj();
	_tween.object = object;
	_tween.property = property;
	_tween.easing = easing;
	_tween.begin = begin;
	_tween.finish = finish;
	_tween.duration = duration;	
	_tween.useSeconds = useSeconds;	
	_tween.loop = loop;
	if(_tween.property.toLowerCase() == "alpha"){
		_tween.begin  = _tween.begin *100;
		_tween.finish = _tween.finish*100;
	}			
	AN.tweens.push(_tween);
	_tween.play(AN.tweens.length-1);

	return _tween;
}

 

/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- End --------------------------------------- */
/* -------------------------- Animation Engine--------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
 





/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- Start ------------------------------------- */
/* -------------------------- Ajax -------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/*
-------------------------------------------------------------------------
- XMLHttpRequest
- XMLHttpRequest.onreadystatechange
- XMLHttpRequest.readyState 
	0 = The request is not initialized
	1 = The request has been set up
	2 = The request has been sent
	3 = The request is in process
	4 = The request is complete
- XMLHttpRequest.status == 200
- XMLHttpRequest.statusText
- XMLHttpRequest.getAllResponseHeaders()
- XMLHttpRequest.getResponseHeader('Last-Modified')
- XMLHttpRequest.open("GET","time.asp",true);
	1. Method [GET/POST]
	2. URL [?data1=abc&data2=def]
	3. asynchronously [true/false]
- xmlHttp.send(null);
-------------------------------------------------------------------------
*/
var AX = {
	http : null,
	init : function (){
		this.http = this.newXmlHttpRequest();
	},
	newXmlHttpRequest : function (){
		var xmlHttp;
		try{// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}catch (e){	
			try{ // Internet Explorer
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}catch (e){
				try{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}catch (e){
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		return xmlHttp;
	},
	open : function(method, url, asyn, func){
		var http = this.newXmlHttpRequest();
		if(!method) asyn = "post";
		if(!asyn) asyn = true;
		if(!url){
			CE.alert("miss url");
			return;
		}
		http.onreadystatechange = function(){
			if(http.readyState == 4){
				func(http);
			}
		}		
		http.open(method, url, asyn);
		http.send(null);
		return http;
	}	
}
AX.init();

/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- End---------------------------------------- */
/* -------------------------- Ajax -------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
  


  
function _confirm (e, msg){
	this.id = '_confirm';
	var cont = null;
	var textObj = null;
	var yesBtn = null;
	var noBtn = null;
	this.returnValue = null;
	this.returnAction = function(){
		alert("_confirm.this.returnAction");
	} 	
	this.confirmOnClick = function(_evt){
		var _thisObj = CE.eventObj(_evt);
		var lower = CE.getParentByClassName(_thisObj, "lower");
		cont.style.display = "none";
		PU.closePopUp(lower.k);
		_thisObj.parentObj.returnValue = (_thisObj.id == "yesBtn") ? true : false;
		_thisObj.parentObj.returnAction();
	}
	if(CE.$("cont") == null){
		cont = CE.newObj("div", "cont", "cont", "cont");			
		textObj = CE.newObj("label", "textObj", "textObj", "textObj");
		yesBtn = CE.newObj("input", "yesBtn", "yesBtn", "yesBtn");			
		yesBtn.type = "button";
		yesBtn.value = "Yes";
		yesBtn.parentObj = this;
		noBtn = CE.newObj("input", "noBtn", "noBtn", "noBtn");			
		noBtn.type = "button";
		noBtn.value = "No";
		noBtn.parentObj = this;
		CE.addEventListener(yesBtn, "click", this.confirmOnClick);
		CE.addEventListener(noBtn, "click", this.confirmOnClick);			
		cont.style.display = "none";
		cont.style.border = "1px solid red";
		cont.appendChild(textObj);
		cont.appendChild(yesBtn);
		cont.appendChild(noBtn);
		document.body.appendChild(cont);
	}else{
		cont = CE.$("cont");
		textObj = CE.$("textObj");
	}
	textObj.innerHTML = msg;
	popup(e, cont, "width:400;height:100;closeButton:false;maxButton:false");
	cont.style.display = "";

	return this;
}

 

/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- Start ------------------------------------- */
/*DE ------------------------ Date -------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */

var DE = {
	weekText : [
				["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
				["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
				["S", "M", "T", "W", "T", "F", "S"]				
	],
	monthText : [
				["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
				["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
	],
	dateDiff : function(date1, date2, returnType){
		//since 1970/01/01
		var diff = null;
		var ms_date1 = date1.getTime();
		var ms_date2 = date2.getTime();
		diff = ms_date1 - ms_date2;
		if(returnType){
			var _sec = diff/1000;
			var _min = _sec/60;
			var _hour = _min/60;
			var _day = _hour/24;
//			var _month = _day/30;
			var _year = _day/365;
			if(returnType == "year"){
				_return = _year;
			}else if(returnType == "month"){
			}else if(returnType == "day"){
				_return = _day;
			}else if(returnType == "hour"){
				_return = _hour;
			}else if(returnType == "min"){
				_return = _min;
			}else if(returnType == "sec"){
				_return = _sec;
			}
		}else{
			_return = diff;	
		}
		return _return;
	},
	withInValidRange : function(_dateObj, _from, _to){
		var _flag = true;
		if(_from != undefined){
			if(DE.dateDiff(_dateObj, _from) < 0){
				_flag = false;
			} 	
		}
		if(_to != undefined){
			if(DE.dateDiff(_dateObj, _to) > 0){
				_flag = false;
			}
		}			
		return _flag;
	},
	isValidMonthText : function(typeNum, value){
		var valid = false;
		for(var i=0; i<this.monthText[typeNum].length; i++){
			if(this.monthText[typeNum][i] == value){
				valid = true;
				break;
			}
		}
		return valid;
	},
	getMonthNumber : function(type, value){
		var c = null;
		for(var i=0; i<this.monthText[type].length; i++){
			if(this.monthText[type][i].toLowerCase() == value.toLowerCase()){
				c = i;
				break;
			}
		}
		return c;
	},
	dateFormatStrToAry : function(str){
		var sep = this.getDateSep(str);		
		var format = [null, null, null];
		var strAry = str.split(sep);
		for(var i=0; i<format.length; i++){
			format[i] = strAry[i];
		}
		format.push(sep);
		return format;
	},
	getDateFormat : function(str){
		var format = [null, null, null];
	/*
		sep > none, space, "-", "/"
		d > 1-9 > no zero
		dd > 01-09 > width zero
		m > 1-9 > no zero
		mm > 01-09 > width zero
		mon > Jun, Feb, Mar
		month > Junuary, February, March
		
		ddmmyyyy > 02122007
		dd-mm-yyyy > 01-10-2009
		d-m-yyyy > 1-5-2009
		d mon yyyy > 5 Feb 2009
		dd mon yyyy > 02 Feb 2009
		d month, yyyy > 2 February, 2009
		d th month, yyyy >. 2 nd February, 2009
	*/
		str = CE.trim(str);
		var sep = this.getDateSep(str);
		var D = str.split(sep);
		function showDateErr(_num){
			//CE.alert("("+_num + "). Date format is not acceptable! >>>> " + str );	
		}
		if(D.length != 3){
			showDateErr(4);
			return null;
		}else{
			var _dd = null; // position number in format array.
			var _mm = null;
			var _yy = null;
			for(var i=0; i<format.length; i++){
				if(D[i].length == 5){
					if(DE.isValidMonthText(0, D[i]) && _mm == null){
						if(_mm == null){
							format[i] = "month";
							_mm = i;
						}
					}
				}else if(D[i].length == 4){
					if(CE.isNumber(D[i])){
						if(_yy == null){
							format[i] = "yyyy";
							_yy = i;
						}
					}
				}else if(D[i].length == 3 && _mm == null){
					if(DE.isValidMonthText(1, D[i])){
						format[i] = "mon";
						_mm = i;					
					}
				}else if(D[i].length == 1 || D[i].length == 2){
					var num = parseFloat(D[i]);
					if(num > 0 && num <= 31){
						if(_dd == null && _mm == null){							
							if(D[i].length == 1 && num < 10){
								format[i] = "d";
							}else{
								format[i] = "dd";	
							}						
//							format[i] = "dd";								
							_dd = i;
						}else if(_dd != null && _mm == null){
							if(num > 0 && num <= 12){								
								if(D[i].length == 1 && num < 10){
									format[i] = "m";
								}else{
									format[i] = "mm";
								}
//								alert(format[i] + "___" + num);
//								format[i] = "mm";								
								_mm = i;
							}else{
								if(parseFloat(D[_dd]) <= 12){

									if(D[_dd].length == 1 && D[_dd] < 10){
										format[_dd] = "mm";
									}else{
										format[_dd] = "m";
									}
									if(D[i].length == 1 && num < 10){
										format[i] = "dd";
									}else{
										format[i] = "d";
									}									
	
//									format[_dd] = "mm";
//									format[i] = "dd";
								}else{
									showDateErr(1);
								}
							}
						}
					}else{
						showDateErr(2);						
					}
				}
			}
			var isValid = true;
			for(var i=0; i<format.length; i++){
				if(format[i] == null)
					isValid = false;
			}
			if(!isValid){
				showDateErr(3);
				return null;	
			}else{
				format.push(sep);
				//alert(format);
				return format;	
			}
		}
	},
	getDateSep : function(str){
		var seps = [" ", "-", "/"];
		var sep = null;
		var c = 0;
		for(var i=0; i<seps.length; i++){
			if(str.match(seps[i]) != null){
				sep = seps[i];
				c++;
			}
		}
		if(c != 1)
			sep = null;
		return sep;
	},
	dateObjToStr : function(dateObj, dateFormat){ 
		var	str = "";
		var dt = dateFormat;
		for(var i=0; i<=2; i++){
			if(dt[i] == "dd"){
				str = str + ((dateObj.getDate()<10) ? "0"+dateObj.getDate() : dateObj.getDate()) + dt[3];
			}else if(dt[i] == "d"){
				str = str + dateObj.getDate() + dt[3];
			}else if(dt[i] == "mm"){
				//str = str + eval(dateObj.getMonth()+1) + dt[3];
				str = str + ((eval(dateObj.getMonth()+1)<10) ? "0"+eval(dateObj.getMonth()+1) : eval(dateObj.getMonth()+1)) + dt[3];				
			}else if(dt[i] == "m"){
				str = str + eval(dateObj.getMonth()+1) + dt[3];
			}else if(dt[i] == "mon"){
				str = str + DE.monthText[1][dateObj.getMonth()] + dt[3];
			}else if(dt[i] == "month"){
				str = str + DE.monthText[0][dateObj.getMonth()] + dt[3];
			}else if(dt[i] == "yyyy"){
				str = str + dateObj.getFullYear() + dt[3];
			}
		}
		str = str.substr(0, str.length-1);
		return str;
	},
	strToDateObj : function(str, dateFormat){ 
		if(str == undefined || str == null){
			return null;
		}
		// no format, auto detect it.
		var format = (dateFormat == undefined) ? DE.getDateFormat(str) : dateFormat;
		if(format == null)
			return null;
		if(DE.getDateFormat(str) != null){
			if(DE.getDateFormat(str).toString() != dateFormat.toString())
				return null;
		}else{
			return null;			
		}
		var _dateObj = new Date();		
		var D = str.split(format[3]);
		var dd = null;
		var mm = null;
		var yy = null;
		for(var i=0; i<3; i++){
			if(format[i] == "dd"){
				dd = parseFloat(D[i]);
			}else if(format[i] == "mm"){
				mm = parseFloat(D[i]) - 1;
			}else if(format[i] == "mon"){				
				mm = DE.getMonthNumber(1, D[i]);
			}else if(format[i] == "month"){
				mm = DE.getMonthNumber(0, D[i]);
			}else if(format[i] == "yyyy"){
				yy = parseFloat(D[i]);
			}
		}
		if(dd != null && mm != null && yy != null){
			_dateObj.setFullYear(yy);			
			_dateObj.setMonth(mm, dd);
			_dateObj.setHours(0,0,0,0);
			if(_dateObj.getMonth() != mm ){ //check 29,30,31
				return null;
			}
			return _dateObj;
		}else{
			CE.alert("DE.strToDateObj " + "dd_" + dd  + "mm_" + mm  + "yy_" + yy );
			return null;
		}
	}
}
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- End --------------------------------------- */
/*DE ------------------------ Date -------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */














/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- Start ------------------------------------- */
/*MK ------------------------ Mask -------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */


var MK = {
	init : function(){
		 //this.buildMask();
		CE.addEventListener(document, "keydown", this.documentOnKeyDown);		 
		CE.addEventListener(window, "scroll", this.documentOnScroll);
	},	
	documentOnScroll : function(e){ 
		var loadIcon = CE.$("loadingIcon");
		if(loadIcon != null){
			var doc = CE.docPty();			
			loadIcon.style.top = doc.H/2 + doc.sT + "px";
		}
	},	
	documentOnKeyDown : function(e){ 
		MK.changeMaskByKeyPress(e);
	},
	changeMaskByKeyPress : function(e){ 
		//ctrlKey, altKey, shiftKey
			//118 - F7
			//119 - F8
		if(e.altKey == true){		
			if(e.keyCode == 118){
				enableMask();
			}
			if(e.keyCode == 119){
				disableMask();
			}
		} 
	},	
	buildMask : function(){		
		var loadIcon = CE.createElement("img");
		loadIcon.id = "loadingIcon";
		loadIcon.src = "../images/loading_103.gif";
		loadIcon.className = "loadingIcon";
		document.body.appendChild(loadIcon);
		
		var loadIconPty = CE.pty(loadIcon);	
		loadIcon.style.display = "none";	
		loadIcon.style.zIndex = 9999;
		
		var doc = CE.docPty();
		loadIcon.style.position = "absolute";
		loadIcon.style.top = doc.H/2 - loadIconPty.H/2 + doc.sT + "px";
		loadIcon.style.left = doc.W/2 - loadIconPty.W/2 + "px";
		
		var img = CE.createElement("img");
		img.id = "disableMask";
		img.src = "../images/spacer.gif";
		img.className = "disableMask";
		document.body.appendChild(img);
		img.style.display = "none";
		img.style.backgroundColor = "#DDD";
		img.style.position = "absolute";
		img.style.top = 0;
		img.style.left = 0;		
		img.style.zIndex = 9998;		
		var doc = CE.docPty();
		img.style.width = "100%";
		img.style.height = doc.sH + "px";
		var value = 30;
		img.style.opacity = value/100;
		img.style.filter = "alpha(opacity="+value+")";		
	}
}
window.addLoadEvent(function() { MK.init(); });   

function enableMask(){
	var mask = CE.$("disableMask");
	var loadIcon = CE.$("loadingIcon");		
	if(mask == null){
		MK.buildMask();
		mask = CE.$("disableMask");		
		loadIcon = CE.$("loadingIcon");				
		mask.style.display = "";
		loadIcon.style.display = "";		
	}else{
		mask.style.display = "";
		loadIcon.style.display = "";
	}
}
function disableMask(){
	var mask = CE.$("disableMask");
	var loadIcon = CE.$("loadingIcon");	
	if(mask == null){
	}else{
		mask.style.display = "none";
		loadIcon.style.display = "none";		
	}		
}




/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* -------------------------- End --------------------------------------- */
/*MK ------------------------ Mask -------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */




















 
